
package com.medranocg.gd

import com.medranocg.gd.DocumentFile

class DocumentFilesHandler {

    def baseDir
    
    def DocumentFilesHandler(String baseDir) {
        this.baseDir = baseDir
    }

    def listFiles() {
        def files = new File(baseDir).listFiles({ d, f -> 
            f ==~ /(?i).*\.pdf/
        } as FilenameFilter).collect { f ->
            [fileName: f.name]
        }

        files.sort { it.fileName }
    }   

    def getFile(String fileName) {
        new DocumentFile(baseDir, fileName)
    }

}

